/**
 * 
 */
package com.alstudio.ui.module.voip;

import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.text.TextUtils;
import android.view.View;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;

import com.alstudio.app.ALLocalEnv;
import com.alstudio.core.voip.ALVoipCallManager;
import com.alstudio.module.xmpp.protocol.xmpp.packact.ALMessage;
import com.alstudio.module.xmpp.request.ALUiXmppRequestCreator;
import com.alstudio.pojo.module.user.User;
import com.alstudio.ui.base.TitleBarActivity;
import com.alstudio.ui.config.BaseTitleActivityConfig;
import com.alstudio.ui.module.economy.UserWalletActivity;
import com.alstudio.ui.module.user.UserHomePageAcitivty;
import com.alstudio.ui.module.voip.CallHistoryAdapter.AddOnIconClickListener;
import com.alstudio.utils.asyncTask.ALAsycTask;
import com.alstudio.utils.asyncTask.ALAsyncTaskCallback;
import com.alstudio.view.ViewUtils;
import com.alstudio.view.listview.PullRefreshAndLoadMoreView;
import com.alstudio.view.viewpagerextend.ALViewpagerCreator;
import com.alstudio.view.viewpagerextend.BaseFixedTabView;
import com.alstudio.view.viewpagerextend.FixedTabsView;
import com.alstudio.view.viewpagerextend.MyViewPager;
import com.loovee.imaohu.R;
import com.nhaarman.listviewanimations.itemmanipulation.AnimateDismissAdapter;
import com.nhaarman.listviewanimations.itemmanipulation.OnDismissCallback;

/**
 * 电话记录
 * 
 * @author alonso lee
 * 
 */
public class PhoneRecordActivity extends TitleBarActivity implements
		OnPageChangeListener, OnScrollListener {

	private ArrayList<View> views;

	private MyViewPager pager;
	private FixedTabsView mFixedTabsView;
	private ALViewpagerCreator viewPagerCreator;
	private ArrayList<String> titles = new ArrayList<String>();
	private PullRefreshAndLoadMoreView tempCallListView;
	private PullRefreshAndLoadMoreView friendsCallListView;

	private CallHistoryAdapter tempCallAdapter;
	private CallHistoryAdapter friendsCallAdapter;

	private ArrayList<ALMessage> tempCalls = new ArrayList<ALMessage>();
	private ArrayList<ALMessage> friendsCalls = new ArrayList<ALMessage>();

	private TextView tempMissedCall, friendMissedCall;
	private int tempMissedCallHitoryCount = 0;
	private int friendsMissedCallHitoryCount = 0;

	private boolean isSetTempMissedCallReaded = false;
	private boolean isSetFriendsMissedCallReaded = false;
	private boolean isEditing = false;

	private final int TEMP_CALLS = 0;
	private final int FRIENDS_CALLS = 1;
	private int showType = TEMP_CALLS;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.TitleBarActivity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setupView(this, getClass().getSimpleName());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#setupView(android.content.Context,
	 * java.lang.String)
	 */
	@Override
	protected void setupView(Context context, String name) {
		// TODO Auto-generated method stub
		super.setupView(context, name);
		setTitleBarActivityContentView(R.layout.phone_record_activity_layout);
		BaseTitleActivityConfig config = new BaseTitleActivityConfig();
		config.rightUseImageButton(true);
		setConfig(config);
		setCenterTextViewMessage(R.string.TxtUserPhone);

		setRightButtonImageSrc(R.drawable.personal_title_icon_set);

		pager = (MyViewPager) findViewById(R.id.pager);
		mFixedTabsView = (FixedTabsView) findViewById(R.id.fixed_tabs);

		tempCallListView = new PullRefreshAndLoadMoreView(this);
		tempCallListView.removeFootView();
		tempCallListView.setSoundEffectsEnabled(false);
		tempCallListView.disablePullRefresh();
		tempCallListView.setItemClickListener(tempCallHistoryItemClickListener);

		friendsCallListView = new PullRefreshAndLoadMoreView(this);
		friendsCallListView.removeFootView();
		friendsCallListView.setSoundEffectsEnabled(false);
		friendsCallListView.disablePullRefresh();
		friendsCallListView
				.setItemClickListener(friendsCallHistoryItemClickListener);

		tempCallAdapter = new CallHistoryAdapter(getApplicationContext(),
				tempCalls);
		tempCallAdapter.setAddOnIconClickListener(tempCallEditClickListener);
		tempAnimateDismissAdapter = new AnimateDismissAdapter(tempCallAdapter,
				tempOnDismissCallback);
		tempAnimateDismissAdapter.setAbsListView(friendsCallListView
				.getListView());

		friendsCallAdapter = new CallHistoryAdapter(getApplicationContext(),
				friendsCalls);
		friendsCallAdapter
				.setAddOnIconClickListener(friendsCallEditClickListener);
		friendsAnimateDismissAdapter = new AnimateDismissAdapter(
				friendsCallAdapter, friendsOnDismissCallback);
		friendsAnimateDismissAdapter.setAbsListView(tempCallListView
				.getListView());

		tempCallListView.setAdapter(tempCallAdapter);
		friendsCallListView.setAdapter(friendsCallAdapter);

		// 加入title，临时通话、好友通话
		titles.add(getString(R.string.TxtTempCall));
		titles.add(getString(R.string.TxtFriendsCall));
		views = new ArrayList<View>();
		views.add(tempCallListView);
		views.add(friendsCallListView);

		viewPagerCreator = new ALViewpagerCreator(ALLocalEnv.getLocalEnv()
				.getGlobalLayoutInflater(), titles, views);
		viewPagerCreator.setViewPager(pager);
		viewPagerCreator.setFixedTabsView(mFixedTabsView);
		viewPagerCreator.addOnPageChangeListener(this);
		viewPagerCreator.commit();

		BaseFixedTabView tab = (BaseFixedTabView) viewPagerCreator
				.getFixedTabsView().getTabView().get(0);
		tempMissedCall = tab.num;
		tab = (BaseFixedTabView) viewPagerCreator.getFixedTabsView()
				.getTabView().get(1);
		friendMissedCall = tab.num;

		setViewOnclickListener(R.id.gold, this);
		setViewOnclickListener(R.id.price, this);
		setRightButtonClickListener(this);

	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		showUserGold();
		showUserCallPrice();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#onStart()
	 */
	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		initData();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#finish()
	 */
	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
		onPageSelected(0);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.alstudio.ui.base.BaseActivity#initData()
	 */
	@Override
	protected void initData() {
		// TODO Auto-generated method stub
		if (!isUIinited) {
			isUIinited = true;
			loadTempCallHistory();
			loadFriendsCallHistory();
			loadMissedCallCount();
			// 重置未接電話數目
			ALVoipCallManager.getDefaultALVoipManager().resetMissedCallCount();
			resetVoipCallNotification();
		}
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		super.onClick(v);
		switch (v.getId()) {
		case R.id.gold:
			// invokeUserGoldClickEvent();
			break;
		case R.id.price:
			invokeCallPriceClickEvent();
			break;
		}
	}
	
	/* (non-Javadoc)
	 * @see com.alstudio.ui.base.TitleBarActivity#invokeRightBtnClick()
	 */
	@Override
	protected void invokeRightBtnClick() {
		// TODO Auto-generated method stub
		super.invokeRightBtnClick();
		invokeEditBtnClickEvent();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.ui.base.BaseActivity#handleNewMissedCallEvent(java.lang.
	 * String)
	 */
	@Override
	public void handleNewMissedCallEvent(String callId) {
		// TODO Auto-generated method stub
		super.handleNewMissedCallEvent(callId);
		loadMissedCallCount();
		modifyCallHistory(callId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.ui.base.BaseActivity#handleReloadCallInfoEvent(java.lang
	 * .String)
	 */
	@Override
	public void handleReloadCallInfoEvent(String callId) {
		// TODO Auto-generated method stub
		super.handleReloadCallInfoEvent(callId);
		modifyCallHistory(callId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.ui.base.BaseActivity#handleCallEstablisedEvent(java.lang
	 * .String)
	 */
	@Override
	public void handleCallEstablisedEvent(String callId) {
		// TODO Auto-generated method stub
		super.handleCallEstablisedEvent(callId);
		modifyCallHistory(callId);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.ui.base.BaseActivity#handleForceRefreshCallHistoryEvent()
	 */
	@Override
	public void handleForceRefreshCallHistoryEvent() {
		// TODO Auto-generated method stub
		super.handleForceRefreshCallHistoryEvent();
		tempCalls.clear();
		tempCallAdapter.notifyDataSetChanged();
		friendsCalls.clear();
		friendsCallAdapter.notifyDataSetChanged();
		loadTempCallHistory();
		loadFriendsCallHistory();
		loadMissedCallCount();

	}

	/**
	 * 显示用户余额
	 */
	private void showUserGold() {
		String msg = getString(R.string.TxtMyGold);
		msg = String.format(msg, ALLocalEnv.getLocalEnv().getMyProfile()
				.getGold());
		showTextMessage(R.id.gold, msg);
	}

	/**
	 * 显示用户通话 价格
	 */
	private void showUserCallPrice() {
		String msg = getString(R.string.TxtCallPrice2);
		msg = String.format(msg, ALLocalEnv.getLocalEnv().getMyProfile()
				.getCallPrice());
		showTextMessage(R.id.price, msg);
	}

	private void invokeCallPriceClickEvent() {
		Intent i = new Intent(this, SetVoipCallPriceActivity.class);
		startActivity(i);
	}

	private void invokeUserGoldClickEvent() {
		Intent i = new Intent(this, UserWalletActivity.class);
		startActivity(i);
	}

	private void invokeEditBtnClickEvent() {

		CallHistoryAdapter adapter = friendsCallAdapter;
		if (showType == TEMP_CALLS) {
			adapter = tempCallAdapter;
		}
		isEditing = !isEditing;

		adapter.setShowDelete(isEditing);
		adapter.notifyDataSetChanged();

		if (!isEditing) {
			setRightButtonImageSrc(R.drawable.personal_title_icon_set);
		} else {

			// pager.setPagingEnabled(false);
			setRightButtonImageSrc(R.drawable.friend_title_icon_confirm);
		}
		pager.setPagingEnabled(!isEditing);

		mFixedTabsView.setClickEnable(!isEditing);
	}

	private OnItemClickListener tempCallHistoryItemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long id) {
			// TODO Auto-generated method stub
			if (id == -1) {
				// 点击的是headerView或者footerView
				return;
			}
			int realPosition = (int) id;
			ALMessage callInfo = tempCalls.get(realPosition);
			if (callInfo == null)
				return;
			User u = (User) callInfo.getData();
			Intent i = new Intent(PhoneRecordActivity.this,
					UserHomePageAcitivty.class);
			i.putExtra("user", u);
			startActivity(i);
		}
	};

	private OnItemClickListener friendsCallHistoryItemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long id) {
			// TODO Auto-generated method stub

			if (id == -1) {
				// 点击的是headerView或者footerView
				return;
			}
			int realPosition = (int) id;
			ALMessage callInfo = friendsCalls.get(realPosition);
			if (callInfo == null)
				return;
			User u = (User) callInfo.getData();
			Intent i = new Intent(PhoneRecordActivity.this,
					UserHomePageAcitivty.class);
			i.putExtra("user", u);
			startActivity(i);
		}
	};

	private void resetVoipCallNotification() {
		ALVoipCallManager.getDefaultALVoipManager()
				.removeInCommingCallMissedNotification();
		ALVoipCallManager.getDefaultALVoipManager()
				.removeInCommingCallNoticeNotification();
	}

	// 讀取數據庫中的通话记录

	private ALAsyncTaskCallback loadTempCallHistoryCallback = new ALAsyncTaskCallback() {

		@Override
		public Object onTaskStart(Object obj) {
			// TODO Auto-generated method stub
			tempCalls.addAll(ALLocalEnv.getLocalEnv().getDatabase()
					.getCallHistoryByFriendship(false));
			return null;
		}

		@Override
		public Object onTaskFinish(Object obj) {
			// TODO Auto-generated method stub

			if (tempCalls.size() == 0) {
				tempCallListView.showNoDataInfo(
						R.drawable.me_myphone_icon_empty01,
						getString(R.string.TxtNoCallHistoryHint));
			} else {
				tempCallListView.showRefereshListView();
				tempCallAdapter.notifyDataSetChanged();
			}

			return null;
		}

		@Override
		public Object onTaskCancel() {
			// TODO Auto-generated method stub
			return null;
		}
	};

	// 讀取數據庫
	private ALAsyncTaskCallback loadFriendsCallHistoryCallback = new ALAsyncTaskCallback() {

		@Override
		public Object onTaskStart(Object obj) {
			// TODO Auto-generated method stub
			friendsCalls.addAll(ALLocalEnv.getLocalEnv().getDatabase()
					.getCallHistoryByFriendship(true));
			return null;
		}

		@Override
		public Object onTaskFinish(Object obj) {
			// TODO Auto-generated method stub
			if (friendsCalls.size() == 0) {
				friendsCallListView.showNoDataInfo(
						R.drawable.me_myphone_icon_empty01,
						getString(R.string.TxtNoCallHistoryHint));
			} else {
				friendsCallListView.showRefereshListView();
				friendsCallAdapter.notifyDataSetChanged();
			}
			return null;
		}

		@Override
		public Object onTaskCancel() {
			// TODO Auto-generated method stub
			return null;
		}
	};

	/**
	 * 讀取臨時會話
	 * 
	 * @param msg
	 */
	private void loadTempCallHistory() {
		ALAsycTask loadTempCallHistoryTask = new ALAsycTask(
				loadTempCallHistoryCallback);
		loadTempCallHistoryTask.execute("");
	}

	/**
	 * 讀取好友通話
	 */
	private void loadFriendsCallHistory() {

		ALAsycTask loadFriendsCallHistoryTask = new ALAsycTask(
				loadFriendsCallHistoryCallback);
		loadFriendsCallHistoryTask.execute("");
	}

	/*********************************** 读取数据库 ***************************************/

	private void loadMissedCallCount() {
		// 读取临时未接来电数
		loadTempMissedCallHistoryCount();
		// 读取好友未接来电数
		loadfriendsMissedCallHistoryCount();

	}

	// 讀取數據庫
	private ALAsyncTaskCallback loadTempMissedCallHistoryCountCallback = new ALAsyncTaskCallback() {

		@Override
		public Object onTaskStart(Object obj) {
			// TODO Auto-generated method stub
			tempMissedCallHitoryCount = ALLocalEnv.getLocalEnv().getDatabase()
					.getUnReadCallHistoryByFriendShip(false);
			return null;
		}

		@Override
		public Object onTaskFinish(Object obj) {
			// TODO Auto-generated method stub
			setTempMissedCallCountValue(tempMissedCallHitoryCount);
			return null;
		}

		@Override
		public Object onTaskCancel() {
			// TODO Auto-generated method stub
			return null;
		}
	};

	/**
	 * 讀取临时未接来电个数
	 * 
	 * @param msg
	 */
	private void loadTempMissedCallHistoryCount() {
		ALAsycTask loadTempMissedCallHistoryTask = new ALAsycTask(
				loadTempMissedCallHistoryCountCallback);
		loadTempMissedCallHistoryTask.execute("");
	}

	public void resetTempMissedCallCountValue() {
		tempMissedCallHitoryCount = 0;
		checkTempMissedCallCountShowState();
	}

	public void setTempMissedCallCountValue(int value) {
		tempMissedCallHitoryCount = value;
		tempMissedCall.setText(tempMissedCallHitoryCount + "");
		checkTempMissedCallCountShowState();
	}

	public void tempMissedCallCountIncrement() {
		tempMissedCallHitoryCount += 1;
		tempMissedCall.setText((tempMissedCallHitoryCount) + "");
		checkTempMissedCallCountShowState();
	}

	public void tempMissedCallCountdecrement() {
		tempMissedCallHitoryCount -= 1;
		if (tempMissedCallHitoryCount > 0) {
			tempMissedCall.setText((tempMissedCallHitoryCount) + "");
		} else {
			tempMissedCallHitoryCount = 0;
		}
		checkTempMissedCallCountShowState();
	}

	private void checkTempMissedCallCountShowState() {
		if (tempMissedCallHitoryCount > 0) {
			ViewUtils.showView(tempMissedCall);
		} else {
			ViewUtils.goneView(tempMissedCall);
		}
	}

	// 讀取數據庫
	private ALAsyncTaskCallback loadfriendsMissedCallHistoryCallback = new ALAsyncTaskCallback() {

		@Override
		public Object onTaskStart(Object obj) {
			// TODO Auto-generated method stub
			friendsMissedCallHitoryCount = ALLocalEnv.getLocalEnv()
					.getDatabase().getUnReadCallHistoryByFriendShip(true);
			return null;
		}

		@Override
		public Object onTaskFinish(Object obj) {
			// TODO Auto-generated method stub
			setFriendsMissedCallCountValue(friendsMissedCallHitoryCount);
			return null;
		}

		@Override
		public Object onTaskCancel() {
			// TODO Auto-generated method stub
			return null;
		}
	};

	/**
	 * 讀取好友未接来电个数
	 * 
	 * @param msg
	 */
	private void loadfriendsMissedCallHistoryCount() {
		ALAsycTask loadfriendsMissedCallHistoryTask = new ALAsycTask(
				loadfriendsMissedCallHistoryCallback);
		loadfriendsMissedCallHistoryTask.execute("");
	}

	public void resetFriendsMissedCallCountValue() {
		friendsMissedCallHitoryCount = 0;
		checkFriendsMissedCallCountShowState();
	}

	public void setFriendsMissedCallCountValue(int value) {
		friendsMissedCallHitoryCount = value;
		friendMissedCall.setText(friendsMissedCallHitoryCount + "");
		checkFriendsMissedCallCountShowState();
	}

	public void friendsMissedCallCountIncrement() {
		friendsMissedCallHitoryCount += 1;
		friendMissedCall.setText((friendsMissedCallHitoryCount) + "");
		checkFriendsMissedCallCountShowState();
	}

	public void friendsMissedCallCountdecrement() {
		friendsMissedCallHitoryCount -= 1;
		if (friendsMissedCallHitoryCount > 0) {
			friendMissedCall.setText((friendsMissedCallHitoryCount) + "");
		} else {
			friendsMissedCallHitoryCount = 0;
		}
		checkFriendsMissedCallCountShowState();
	}

	private void checkFriendsMissedCallCountShowState() {
		if (friendsMissedCallHitoryCount > 0) {
			ViewUtils.showView(friendMissedCall);
		} else {
			ViewUtils.goneView(friendMissedCall);
		}
	}

	private void modifyCallHistory(String callId) {
		if (!TextUtils.isEmpty(callId)) {
			ALMessage call = ALLocalEnv.getLocalEnv().getDatabase()
					.getCallHistoryByCallId(callId);
			if (call != null) {
				User u = (User) call.getData();
				if (u.getIsfriend()) {
					if (friendsCalls.contains(call)) {
						friendsCalls.remove(call);
					}
					friendsCalls.add(0, call);
					friendsCallAdapter.notifyDataSetChanged();
					friendsCallListView.showRefereshListView();

				} else {
					if (tempCalls.contains(call)) {
						tempCalls.remove(call);
					}
					tempCalls.add(0, call);
					tempCallAdapter.notifyDataSetChanged();
					tempCallListView.showRefereshListView();
				}
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.support.v4.view.ViewPager.OnPageChangeListener#
	 * onPageScrollStateChanged(int)
	 */
	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.support.v4.view.ViewPager.OnPageChangeListener#onPageScrolled
	 * (int, float, int)
	 */
	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.support.v4.view.ViewPager.OnPageChangeListener#onPageSelected
	 * (int)
	 */
	@Override
	public void onPageSelected(int arg0) {
		// TODO Auto-generated method stub
		showType = arg0;
		if (arg0 == 0) {
			if (!isSetTempMissedCallReaded) {
				isSetTempMissedCallReaded = true;
				new Thread() {
					public void run() {
						ALLocalEnv.getLocalEnv().getDatabase()
								.setAllTempCallHistoryReaded();
					};
				}.start();
			}
		} else {
			if (!isSetFriendsMissedCallReaded) {
				isSetFriendsMissedCallReaded = true;
				new Thread() {
					public void run() {
						ALLocalEnv.getLocalEnv().getDatabase()
								.setAllFriendsCallHistoryReaded();
					};
				}.start();
			}
		}
	}

	/****************************************** 编辑功能 *************************************************/

	private AnimateDismissAdapter friendsAnimateDismissAdapter;;
	private AnimateDismissAdapter tempAnimateDismissAdapter;;

	private OnDismissCallback friendsOnDismissCallback = new OnDismissCallback() {

		@Override
		public void onDismiss(AbsListView arg0, int[] reverseSortedPositions) {
			// TODO Auto-generated method stub
			for (int position : reverseSortedPositions) {
				if (position < friendsCalls.size()) {
					ALMessage msg = friendsCalls.remove(position);
					friendsCallAdapter.notifyDataSetChanged();
					loadMissedCallCount();
					

					// 从数据库中删除
					ALLocalEnv.getLocalEnv().getDatabase()
							.deleteCallHistory(msg.getMsgId());

					User u = (User) msg.getData();
					
					ALUiXmppRequestCreator
							.postALUiXmppVoipDeleteCallHistoryDetail(u.getJid());
					
					if (friendsCalls.size() == 0) {
						loadFriendsCallHistory();
					}

				}
			}
		}
	};

	private OnDismissCallback tempOnDismissCallback = new OnDismissCallback() {

		@Override
		public void onDismiss(AbsListView arg0, int[] reverseSortedPositions) {
			// TODO Auto-generated method stub
			for (int position : reverseSortedPositions) {
				if (position < tempCalls.size()) {
					ALMessage msg = tempCalls.remove(position);
					tempCallAdapter.notifyDataSetChanged();
					// 从数据库中删除
					ALLocalEnv.getLocalEnv().getDatabase()
							.deleteCallHistory(msg.getMsgId());
					User u = (User) msg.getData();
					ALUiXmppRequestCreator
							.postALUiXmppVoipDeleteCallHistoryDetail(u.getJid());

					if (tempCalls.size() == 0) {
						loadTempCallHistory();
					}

					loadMissedCallCount();
				}
			}
		}
	};

	private AddOnIconClickListener tempCallEditClickListener = new AddOnIconClickListener() {

		@Override
		public void onAddOnIconClick(Object obj) {
			// TODO Auto-generated method stub
			// 删除临时通话
			int pos = (Integer) obj;
			tempAnimateDismissAdapter.animateDismiss(pos);

		}
	};

	private AddOnIconClickListener friendsCallEditClickListener = new AddOnIconClickListener() {

		@Override
		public void onAddOnIconClick(Object obj) {
			// TODO Auto-generated method stub
			// 删除好友通话
			int pos = (Integer) obj;
			friendsAnimateDismissAdapter.animateDismiss(pos);

		}
	};

	/*
	 * (non-Javadoc)
	 * 
	 * @see android.widget.AbsListView.OnScrollListener#onScroll(android.widget.
	 * AbsListView, int, int, int)
	 */
	@Override
	public void onScroll(AbsListView view, int firstVisibleItem,
			int visibleItemCount, int totalItemCount) {
		// TODO Auto-generated method stub
		if (isEditing) {
			if (showType == TEMP_CALLS) {
				tempCallAdapter.setShowDeleteBtnAnim(false);
			} else {
				friendsCallAdapter.setShowDeleteBtnAnim(false);
			}
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * android.widget.AbsListView.OnScrollListener#onScrollStateChanged(android
	 * .widget.AbsListView, int)
	 */
	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		// TODO Auto-generated method stub

	}

}
